<!DOCTYPE html>
<!-- saved from url=(0062)../automator/api.html#auto-mode -->
<html lang="zh-CN" data-theme="light" class=" ">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <meta name="generator" content="VuePress 2.0.0-beta.51" />
  <meta name="theme" content="VuePress Theme Hope" />
  <meta property="og:url" content="automator.html">
  <meta property="og:site_name" content="Auto.js Pro文档">
  <meta property="og:title" content="automator与其他函数">
  <meta property="og:type" content="article">
  <meta property="og:updated_time" content="2022-10-22T07:36:15.000Z">
  <meta property="og:locale" content="zh-CN">
  <meta property="og:locale:alternate" content="en-US">
  <meta property="article:modified_time" content="2022-10-22T07:36:15.000Z">
  <link rel="alternate" hreflang="en-us" href="automator.html">
  <link rel="icon" href="../docs/favicon.ico">
  <link rel="manifest" href="../docs/manifest.webmanifest" crossorigin="use-credentials">
  <meta name="theme-color" content="#46bd87">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
  <title>automator与其他函数 | Auto.js Pro文档</title>
  <meta name="description" content="支持Node.js的自动化工作流JavaScript IDE">
  <style>
    :root {
      --bg-color: #fff;
    }

    html[data-theme="dark"] {
      --bg-color: #1d2025;
    }

    html,
    body {
      background-color: var(--bg-color);
    }
  </style>
  <script>
    const userMode = localStorage.getItem("vuepress-theme-hope-scheme");
    const systemDarkMode =
      window.matchMedia &&
      window.matchMedia("(prefers-color-scheme: dark)").matches;

    if (userMode === "dark" || (userMode !== "light" && systemDarkMode)) {
      document.querySelector("html").setAttribute("data-theme", "dark");
    }
  </script>
  <link rel="stylesheet" href="../../../assets/style.ae9cb182.css">
  <link rel="modulepreload" href="../../../assets/app.6aa2b576.js">
  <link rel="modulepreload" href="../../../assets/app.html.004a89b7.js">
  <link rel="modulepreload" href="../../../assets/_plugin-vue_export-helper.cdc0426e.js">
  <link rel="modulepreload" href="../../../assets/app.html.79d7bc17.js">
</head>

<body>
  <!-- Copyright � 2008. Spidersoft Ltd -->
  <style>
    A.applink:hover {
      border: 2px dotted #DCE6F4;
      padding: 2px;
      background-color: #ffff00;
      color: green;
      text-decoration: none
    }

    A.applink {
      border: 2px dotted #DCE6F4;
      padding: 2px;
      color: #2F5BFF;
      background: transparent;
      text-decoration: none
    }

    A.info {
      color: #2F5BFF;
      background: transparent;
      text-decoration: none
    }

    A.info:hover {
      color: green;
      background: transparent;
      text-decoration: underline
    }
  </style>


  <div id="app"><!--[--><!--[--><!--[--><span tabindex="-1"></span><a href="#main-content"
      class="skip-link sr-only">Skip to content</a><!--]-->
    <div class="theme-container has-toc"><!--[--><!--[-->
      <header class="navbar">
        <div class="navbar-left"><button class="toggle-sidebar-button" title="Toggle Sidebar"><span
              class="icon"></span></button><!----><a href="../../../docs.html" class="brand"><img class="logo"
              src="../../../logo.png" alt="Auto.js Pro文档"><!----><span class="site-name hide-in-pad">Auto.js
              Pro文档</span></a><!----></div>
        <div class="navbar-center"><!---->
          <nav class="nav-links">
            <div class="nav-item hide-in-mobile"><a href="../../../docs.html" class="nav-link"
                aria-label="Auto.js Pro"><span class="icon iconfont icon-home"></span>Auto.js Pro<!----></a></div>
            <div class="nav-item hide-in-mobile"><a href="../../guide/guide.html" class="nav-link" aria-label="指南"><span
                  class="icon iconfont icon-creative"></span>指南<!----></a></div>
            <div class="nav-item hide-in-mobile"><a href="../v8.html" class="nav-link active" aria-label="第一代API文档"><span
                  class="icon iconfont icon-note"></span>第一代API文档<!----></a></div>
            <div class="nav-item hide-in-mobile"><a href="../../v9/v9.html" class="nav-link" aria-label="第二代API文档"><span
                  class="icon iconfont icon-note"></span>第二代API文档<!----></a></div>
            <div class="nav-item hide-in-mobile">
              <div class="dropdown-wrapper"><button class="dropdown-title" type="button" aria-label="官网与相关链接"><span
                    class="title"><span class="icon iconfont icon-discover"></span>官网与相关链接</span><span
                    class="arrow"></span>
                  <ul class="nav-dropdown">
                    <li class="dropdown-item"><a href="../../../pro.autojs.html" rel="noopener noreferrer"
                        target="_blank" aria-label="官网与软件下载" class="nav-link"><!---->官网与软件下载<span><svg
                            class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                            focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                            <path fill="currentColor"
                              d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                            </path>
                            <polygon fill="currentColor"
                              points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                            </polygon>
                          </svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a>
                    </li>
                    
                    <li class="dropdown-item"><a href="https://pd.qq.com/s/gosos5" rel="noopener noreferrer"
                        target="_blank" aria-label="官方频道" class="nav-link"><!---->官方频道<span><svg
                            class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"
                            focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                            <path fill="currentColor"
                              d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                            </path>
                            <polygon fill="currentColor"
                              points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                            </polygon>
                          </svg><span class="external-link-icon-sr-only">open in new window</span></span><!----></a>
                    </li>
                  </ul>
                </button></div>
            </div>
          </nav><!---->
        </div>
        <div class="navbar-right"><!---->
          <div class="nav-item">
            <div class="dropdown-wrapper i18n-dropdown"><button class="dropdown-title" type="button"
                aria-label="选择语言"><!--[--><svg xmlns="http://www.w3.org/2000/svg" class="icon i18n-icon"
                  viewBox="0 0 1024 1024" fill="currentColor" aria-label="i18n icon"
                  style="width:1rem;height:1rem;vertical-align:middle;">
                  <path
                    d="M379.392 460.8 494.08 575.488l-42.496 102.4L307.2 532.48 138.24 701.44l-71.68-72.704L234.496 460.8l-45.056-45.056c-27.136-27.136-51.2-66.56-66.56-108.544h112.64c7.68 14.336 16.896 27.136 26.112 35.84l45.568 46.08 45.056-45.056C382.976 312.32 409.6 247.808 409.6 204.8H0V102.4h256V0h102.4v102.4h256v102.4H512c0 70.144-37.888 161.28-87.04 210.944L378.88 460.8zM576 870.4 512 1024H409.6l256-614.4H768l256 614.4H921.6l-64-153.6H576zM618.496 768h196.608L716.8 532.48 618.496 768z">
                  </path>
                </svg><!--]--><span class="arrow"></span>
                <ul class="nav-dropdown">
                  <li class="dropdown-item"><a href="../../../../docs/en/" class="nav-link"
                      aria-label="English"><!---->English<!----></a></li>
                  <li class="dropdown-item"><a aria-current="page"
                      href="../automator.html"
                      class="router-link-active router-link-exact-active nav-link active"
                      aria-label="简体中文"><!---->简体中文<!----></a></li>
                </ul>
              </button></div>
          </div><!---->
          <div class="nav-item hide-in-mobile"><button id="appearance-switch"><svg xmlns="http://www.w3.org/2000/svg"
                class="icon auto-icon" viewBox="0 0 1024 1024" fill="currentColor" aria-label="auto icon"
                style="display:block;">
                <path
                  d="M512 992C246.92 992 32 777.08 32 512S246.92 32 512 32s480 214.92 480 480-214.92 480-480 480zm0-840c-198.78 0-360 161.22-360 360 0 198.84 161.22 360 360 360s360-161.16 360-360c0-198.78-161.22-360-360-360zm0 660V212c165.72 0 300 134.34 300 300 0 165.72-134.28 300-300 300z">
                </path>
              </svg><svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" viewBox="0 0 1024 1024"
                fill="currentColor" aria-label="dark icon" style="display:none;">
                <path
                  d="M524.8 938.667h-4.267a439.893 439.893 0 0 1-313.173-134.4 446.293 446.293 0 0 1-11.093-597.334A432.213 432.213 0 0 1 366.933 90.027a42.667 42.667 0 0 1 45.227 9.386 42.667 42.667 0 0 1 10.24 42.667 358.4 358.4 0 0 0 82.773 375.893 361.387 361.387 0 0 0 376.747 82.774 42.667 42.667 0 0 1 54.187 55.04 433.493 433.493 0 0 1-99.84 154.88 438.613 438.613 0 0 1-311.467 128z">
                </path>
              </svg><svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon" viewBox="0 0 1024 1024"
                fill="currentColor" aria-label="light icon" style="display:none;">
                <path
                  d="M952 552h-80a40 40 0 0 1 0-80h80a40 40 0 0 1 0 80zM801.88 280.08a41 41 0 0 1-57.96-57.96l57.96-58a41.04 41.04 0 0 1 58 58l-58 57.96zM512 752a240 240 0 1 1 0-480 240 240 0 0 1 0 480zm0-560a40 40 0 0 1-40-40V72a40 40 0 0 1 80 0v80a40 40 0 0 1-40 40zm-289.88 88.08-58-57.96a41.04 41.04 0 0 1 58-58l57.96 58a41 41 0 0 1-57.96 57.96zM192 512a40 40 0 0 1-40 40H72a40 40 0 0 1 0-80h80a40 40 0 0 1 40 40zm30.12 231.92a41 41 0 0 1 57.96 57.96l-57.96 58a41.04 41.04 0 0 1-58-58l58-57.96zM512 832a40 40 0 0 1 40 40v80a40 40 0 0 1-80 0v-80a40 40 0 0 1 40-40zm289.88-88.08 58 57.96a41.04 41.04 0 0 1-58 58l-57.96-58a41 41 0 0 1 57.96-57.96z">
                </path>
              </svg></button></div>
          <div class="search-box" role="search" data-v-f3875574=""><input value="" aria-label="Search" class=""
              placeholder="Search" autocomplete="off" spellcheck="false" data-v-f3875574=""><!----></div><!----><button
            class="toggle-navbar-button" aria-label="Toggle Navbar" aria-expanded="false"
            aria-controls="nav-screen"><span class="button-container"><span class="button-top"></span><span
                class="button-middle"></span><span class="button-bottom"></span></span></button>
        </div>
      </header><!----><!--]--><!---->
      <div class="toggle-sidebar-wrapper"><span class="arrow left"></span></div>
      <aside class="sidebar"><!--[--><!----><!--]-->
        <ul class="sidebar-links">
          <li>
            <section class="sidebar-group">
              <p class="sidebar-heading"><!----><span class="title">指南</span><!----></p>
              <ul class="sidebar-links">
                <li><!--[--><a href="./" class="nav-link sidebar-link sidebar-page"
                    aria-label="阅读须知"><!---->阅读须知<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
              </ul>
            </section>
          </li>
          <li>
            <section class="sidebar-group">
              <p class="sidebar-heading active"><!----><span class="title">API文档</span><!----></p>
              <ul class="sidebar-links">
                <li>
                  <section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span
                        class="title">自动化 - 控件操作</span><span class="arrow down"></span></button>
                    <ul class="sidebar-links">
                      <li><!--[--><a href="./index.html"
                          class="nav-link sidebar-link sidebar-page" aria-label="入门介绍"><!---->入门介绍<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                      <li><!--[--><a href="./selector.html"
                          class="nav-link sidebar-link sidebar-page" aria-label="选择器"><!---->选择器<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                      <li><!--[--><a href="./uiobject.html"
                          class="nav-link sidebar-link sidebar-page" aria-label="控件和控件集合"><!---->控件和控件集合<!----></a>
                        <ul class="sidebar-sub-headers"></ul><!--]-->
                      </li>
                      <li><!--[--><a href="./api.html"
                          class="router-link-active router-link-exact-active nav-link sidebar-link sidebar-page active"
                          aria-label="automator与其他函数" aria-current="page"><!---->automator与其他函数<!----></a>
                        <ul class="sidebar-sub-headers">
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-mode"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading active"
                              aria-label="auto([mode])"><!---->auto([mode])<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-waitfor"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.waitFor()"><!---->auto.waitFor()<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-setmode-mode"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.setMode(mode)"><!---->auto.setMode(mode)<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-setflags-flags"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.setFlags(flags)"><!---->auto.setFlags(flags)<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-service"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.service"><!---->auto.service<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-windows"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.windows"><!---->auto.windows<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-root"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.root"><!---->auto.root<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-rootinactivewindow"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.rootInActiveWindow"><!---->auto.rootInActiveWindow<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-setwindowfilter-filter"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.setWindowFilter(filter)"><!---->auto.setWindowFilter(filter)<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-windowroots"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.windowRoots"><!---->auto.windowRoots<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#click-text-i"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="click(text[, i])"><!---->click(text[, i])<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#click-left-top-bottom-right"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="click(left, top, bottom, right)"><!---->click(left, top, bottom,
                              right)<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#longclick-text-i"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="longClick(text[, i]))"><!---->longClick(text[, i]))<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#scrollup-i"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="scrollUp([i])"><!---->scrollUp([i])<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#scrolldown-i"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="scrollDown([i])"><!---->scrollDown([i])<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#settext-i-text"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="setText([i, ]text)"><!---->setText([i, ]text)<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#input-i-text"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="input([i, ]text)"><!---->input([i, ]text)<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#automator-takescreenshot"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="automator.takeScreenshot()"><!---->automator.takeScreenshot()<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#automator-switchtoinputmethod-packagename"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="automator.switchToInputMethod(packageName)"><!---->automator.switchToInputMethod(packageName)<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#automator-headsethook"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="automator.headsetHook()"><!---->automator.headsetHook()<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#auto-clearcache"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="auto.clearCache()"><!---->auto.clearCache()<!----></a>
                            <ul class="sidebar-sub-headers"></ul>
                          </li>
                          <li class="sidebar-sub-header"><a aria-current="page"
                              href="./api.html#rect"
                              class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                              aria-label="Rect"><!---->Rect<!----></a>
                            <ul class="sidebar-sub-headers">
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-left"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.left"><!---->Rect.left<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-right"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.right"><!---->Rect.right<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-top"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.top"><!---->Rect.top<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-bottom"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.bottom"><!---->Rect.bottom<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-centerx"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.centerX()"><!---->Rect.centerX()<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-centery"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.centerY()"><!---->Rect.centerY()<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-width"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.width()"><!---->Rect.width()<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-height"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.height()"><!---->Rect.height()<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-contains-r"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.contains(r)"><!---->Rect.contains(r)<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                              <li class="sidebar-sub-header"><a aria-current="page"
                                  href="./api.html#rect-intersect-r"
                                  class="router-link-active router-link-exact-active nav-link sidebar-link heading"
                                  aria-label="Rect.intersect(r)"><!---->Rect.intersect(r)<!----></a>
                                <ul class="sidebar-sub-headers"></ul>
                              </li>
                            </ul>
                          </li>
                        </ul><!--]-->
                      </li>
                    </ul>
                  </section>
                </li>
                <li><!--[--><a href="../coordinatesBasedAutomation.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="自动化 - 坐标操作"><!---->自动化 - 坐标操作<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../app.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="app - 应用"><!---->app - 应用<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../base64.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="base64"><!---->base64<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../colors.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="colors - 颜色"><!---->colors - 颜色<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../canvas.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="canvas - 画布"><!---->canvas - 画布<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../console.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="console - 控制台"><!---->console -
                    控制台<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../crypto.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="crypto - 加解密与消息摘要"><!---->crypto -
                    加解密与消息摘要<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../debug.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="debug - 调试工具"><!---->debug - 调试工具<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../device.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="device - 设备"><!---->device - 设备<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../dialogs.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="dialogs - 对话框"><!---->dialogs -
                    对话框<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../engines.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="engines - 脚本引擎"><!---->engines -
                    脚本引擎<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../events.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="events - 事件与监听"><!---->events -
                    事件与监听<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../floaty.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="floaty - 悬浮窗"><!---->floaty - 悬浮窗<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../files.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="files - 文件系统"><!---->files - 文件系统<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../globals.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="globals - 全局变量与函数"><!---->globals -
                    全局变量与函数<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../http.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="http - HTTP网络请求"><!---->http -
                    HTTP网络请求<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../images.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="images - 图片处理"><!---->images -
                    图片处理<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../keys.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="keys - 按键模拟"><!---->keys - 按键模拟<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../media.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="media - 多媒体"><!---->media - 多媒体<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../modules.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="module - 模块"><!---->module - 模块<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../ocr.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="ocr - 文字识别"><!---->ocr - 文字识别<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../plugins.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="plugins - 插件"><!---->plugins - 插件<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../powerManager.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="power_manager - 电源管理"><!---->power_manager -
                    电源管理<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../sensors.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="sensors - 传感器"><!---->sensors -
                    传感器<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../shell.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="shell - Shell命令"><!---->shell -
                    Shell命令<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../storages.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="storages - 本地存储"><!---->storages -
                    本地存储<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../settings.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="settings - 设置"><!---->settings -
                    设置<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../threads.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="threads - 多线程"><!---->threads -
                    多线程<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../timers.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="timers - 定时器"><!---->timers - 定时器<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../timedTasks.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="work_manager - 定时与任务"><!---->work_manager -
                    定时与任务<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li>
                  <section class="sidebar-group"><button class="sidebar-heading clickable"><!----><span class="title">ui
                        - 用户界面</span><span class="arrow right"></span></button><!----></section>
                </li>
                <li><!--[--><a href="../util.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="util - 工具"><!---->util - 工具<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../webSocket.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="WebSocket"><!---->WebSocket<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
                <li><!--[--><a href="../zip.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="zip - 压缩与解压"><!---->zip - 压缩与解压<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
              </ul>
            </section>
          </li>
          <li>
            <section class="sidebar-group">
              <p class="sidebar-heading"><!----><span class="title">进阶</span><!----></p>
              <ul class="sidebar-links">
                <li><!--[--><a href="../scriptingJava.html"
                    class="nav-link sidebar-link sidebar-page" aria-label="和Java交互"><!---->和Java交互<!----></a>
                  <ul class="sidebar-sub-headers"></ul><!--]-->
                </li>
              </ul>
            </section>
          </li>
        </ul><!--[--><!----><!--]-->
      </aside><!--[-->
      <main class="page" id="main-content"><!---->
        <nav class="breadcrumb">
          <ol vocab="https://schema.org/" typeof="BreadcrumbList">
            <li class="" property="itemListElement" typeof="ListItem"><a href="/docs/" class=""
                property="item" typeof="WebPage"><span class="icon iconfont icon-home"></span><span
                  property="name">Auto.js Pro</span></a>
              <meta property="position" content="1">
            </li>
            <li class="" property="itemListElement" typeof="ListItem"><a href="../"
                class="" property="item" typeof="WebPage"><!----><span property="name">阅读须知</span></a>
              <meta property="position" content="2">
            </li>
            <li class="" property="itemListElement" typeof="ListItem"><a
                href="../automator/" class="" property="item"
                typeof="WebPage"><!----><span property="name">入门介绍</span></a>
              <meta property="position" content="3">
            </li>
            <li class="is-active" property="itemListElement" typeof="ListItem"><a aria-current="page"
                href="../automator/api.html"
                class="router-link-active router-link-exact-active" property="item" typeof="WebPage"><!----><span
                  property="name">automator与其他函数</span></a>
              <meta property="position" content="4">
            </li>
          </ol>
        </nav>
        <div class="page-title">
          <h1><!---->automator与其他函数</h1>
          <div class="page-info"><span class="date-info" aria-label="写作日期📅" data-balloon-pos="down"><svg
                xmlns="http://www.w3.org/2000/svg" class="icon calendar-icon" viewBox="0 0 1024 1024"
                fill="currentColor" aria-label="calendar icon">
                <path
                  d="M716.4 110.137c0-18.753-14.72-33.473-33.472-33.473-18.753 0-33.473 14.72-33.473 33.473v33.473h66.993v-33.473zm-334.87 0c0-18.753-14.72-33.473-33.473-33.473s-33.52 14.72-33.52 33.473v33.473h66.993v-33.473zm468.81 33.52H716.4v100.465c0 18.753-14.72 33.473-33.472 33.473a33.145 33.145 0 01-33.473-33.473V143.657H381.53v100.465c0 18.753-14.72 33.473-33.473 33.473a33.145 33.145 0 01-33.473-33.473V143.657H180.6A134.314 134.314 0 0046.66 277.595v535.756A134.314 134.314 0 00180.6 947.289h669.74a134.36 134.36 0 00133.94-133.938V277.595a134.314 134.314 0 00-133.94-133.938zm33.473 267.877H147.126a33.145 33.145 0 01-33.473-33.473c0-18.752 14.72-33.473 33.473-33.473h736.687c18.752 0 33.472 14.72 33.472 33.473a33.145 33.145 0 01-33.472 33.473z">
                </path>
              </svg><span>2022年10月27日</span>
              <meta property="datePublished" content="2022-10-27T05:15:37.000Z">
            </span></div>
          <hr>
        </div>
        <div class="toc-place-holder">
          <aside id="toc">
            <div class="toc-header">此页内容</div>
            <div class="toc-wrapper">
              <ul class="toc-list">
                <li class="toc-item active"><a aria-current="page"
                    href="../automator/api.html#auto-mode"
                    class="router-link-active router-link-exact-active toc-link level2">auto([mode])</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-waitfor"
                    class="router-link-active router-link-exact-active toc-link level2">auto.waitFor()</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-setmode-mode"
                    class="router-link-active router-link-exact-active toc-link level2">auto.setMode(mode)</a></li>
                <!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-setflags-flags"
                    class="router-link-active router-link-exact-active toc-link level2">auto.setFlags(flags)</a></li>
                <!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-service"
                    class="router-link-active router-link-exact-active toc-link level2">auto.service</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-windows"
                    class="router-link-active router-link-exact-active toc-link level2">auto.windows</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-root"
                    class="router-link-active router-link-exact-active toc-link level2">auto.root</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-rootinactivewindow"
                    class="router-link-active router-link-exact-active toc-link level2">auto.rootInActiveWindow</a></li>
                <!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-setwindowfilter-filter"
                    class="router-link-active router-link-exact-active toc-link level2">auto.setWindowFilter(filter)</a>
                </li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-windowroots"
                    class="router-link-active router-link-exact-active toc-link level2">auto.windowRoots</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#click-text-i"
                    class="router-link-active router-link-exact-active toc-link level2">click(text[, i])</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#click-left-top-bottom-right"
                    class="router-link-active router-link-exact-active toc-link level2">click(left, top, bottom,
                    right)</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#longclick-text-i"
                    class="router-link-active router-link-exact-active toc-link level2">longClick(text[, i]))</a></li>
                <!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#scrollup-i"
                    class="router-link-active router-link-exact-active toc-link level2">scrollUp([i])</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#scrolldown-i"
                    class="router-link-active router-link-exact-active toc-link level2">scrollDown([i])</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#settext-i-text"
                    class="router-link-active router-link-exact-active toc-link level2">setText([i, ]text)</a></li>
                <!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#input-i-text"
                    class="router-link-active router-link-exact-active toc-link level2">input([i, ]text)</a></li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#automator-takescreenshot"
                    class="router-link-active router-link-exact-active toc-link level2">automator.takeScreenshot()</a>
                </li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#automator-switchtoinputmethod-packagename"
                    class="router-link-active router-link-exact-active toc-link level2">automator.switchToInputMethod(packageName)</a>
                </li><!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#automator-headsethook"
                    class="router-link-active router-link-exact-active toc-link level2">automator.headsetHook()</a></li>
                <!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#auto-clearcache"
                    class="router-link-active router-link-exact-active toc-link level2">auto.clearCache()</a></li>
                <!---->
                <li class="toc-item"><a aria-current="page"
                    href="../automator/api.html#rect"
                    class="router-link-active router-link-exact-active toc-link level2">Rect</a></li>
                <ul class="toc-list">
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-left"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.left</a></li><!---->
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-right"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.right</a></li><!---->
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-top"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.top</a></li><!---->
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-bottom"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.bottom</a></li><!---->
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-centerx"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.centerX()</a></li><!---->
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-centery"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.centerY()</a></li><!---->
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-width"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.width()</a></li><!---->
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-height"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.height()</a></li><!---->
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-contains-r"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.contains(r)</a></li>
                  <!---->
                  <li class="toc-item"><a aria-current="page"
                      href="../automator/api.html#rect-intersect-r"
                      class="router-link-active router-link-exact-active toc-link level3">Rect.intersect(r)</a></li>
                  <!---->
                </ul>
              </ul>
            </div>
          </aside>
        </div><!---->
        <div class="theme-hope-content">
          <h1 id="automator与其他函数" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#automator%E4%B8%8E%E5%85%B6%E4%BB%96%E5%87%BD%E6%95%B0"
              aria-hidden="true">#</a> automator与其他函数</h1>
          <h2 id="auto-mode" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-mode" aria-hidden="true">#</a>
            auto([mode])</h2>
          <ul>
            <li><code><span class="token property">mode</span></code> {string} 模式</li>
          </ul>
          <p>检查无障碍服务是否已经启用，如果没有启用则抛出异常并跳转到无障碍服务启用界面；同时设置无障碍模式为mode。mode的可选值为：</p>
          <ul>
            <li><code><span class="token property">fast</span></code>
              快速模式。该模式下会启用控件缓存，从而选择器获取屏幕控件更快。对于需要快速的控件操作的脚本可以使用该模式，一般脚本则没有必要使用该函数。</li>
            <li><code><span class="token property">normal</span></code> 正常模式，默认。</li>
          </ul>
          <p>如果不加mode参数，则为正常模式。</p>
          <p>
            建议使用<code>auto<span class="token punctuation">.</span><span class="token function">waitFor</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>和<code>auto<span class="token punctuation">.</span><span class="token function">setMode</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>代替该函数，因为<code><span class="token function">auto</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>函数如果无障碍服务未启动会停止脚本；而<code>auto<span class="token punctuation">.</span><span class="token function">waitFor</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>则会在在无障碍服务启动后继续运行。
          </p>
          <p>示例：</p>
          <div class="language-javascript ext-js line-numbers-mode"><button class="copy" aria-label="复制代码"
              data-copied="已复制" data-balloon-pos="left">
              <div class="copy-icon"></div>
            </button>
            <pre class="language-javascript" copy-code-registered=""><code><span class="token function">auto</span><span class="token punctuation">(</span><span class="token string">"fast"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
            </div>
          </div>
          <p>示例2：</p>
          <div class="language-javascript ext-js line-numbers-mode"><button class="copy" aria-label="复制代码"
              data-copied="已复制" data-balloon-pos="left">
              <div class="copy-icon"></div>
            </button>
            <pre class="language-javascript" copy-code-registered=""><code><span class="token function">auto</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="auto-waitfor" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-waitfor" aria-hidden="true">#</a>
            auto.waitFor()</h2>
          <p>检查无障碍服务是否已经启用，如果没有启用则跳转到无障碍服务启用界面，并等待无障碍服务启动；当无障碍服务启动后脚本会继续运行。</p>
          <p>
            因为该函数是阻塞的，因此除非是有协程特性，否则不能在ui模式下运行该函数，建议在ui模式下使用<code><span class="token function">auto</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>函数。
          </p>
          <h2 id="auto-setmode-mode" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-setmode-mode" aria-hidden="true">#</a>
            auto.setMode(mode)</h2>
          <ul>
            <li><code><span class="token property">mode</span></code> {string} 模式</li>
          </ul>
          <p>设置无障碍模式为mode。mode的可选值为：</p>
          <ul>
            <li><code><span class="token property">fast</span></code>
              快速模式。该模式下会启用控件缓存，从而选择器获取屏幕控件更快。对于需要快速的控件查看和操作的脚本可以使用该模式，一般脚本则没有必要使用该函数。</li>
            <li><code><span class="token property">normal</span></code> 正常模式，默认。</li>
          </ul>
          <h2 id="auto-setflags-flags" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-setflags-flags" aria-hidden="true">#</a>
            auto.setFlags(flags)</h2>
          <p><strong>[v4.1.0新增]</strong></p>
          <ul>
            <li><code><span class="token property">flags</span></code> {string} | {Array} 一些标志，来启用和禁用某些特性，包括： <ul>
                <li><code><span class="token property">findOnUiThread</span></code>
                  使用该特性后，选择器搜索时会在主进程进行。该特性用于解决线程安全问题导致的次生问题，不过目前貌似已知问题并不是线程安全问题。</li>
                <li><code><span class="token property">useUsageStats</span></code>
                  使用该特性后，将会以"使用情况统计"服务的结果来检测当前正在运行的应用包名（需要授予"查看使用情况统计"权限)。如果觉得currentPackage()返回的结果不太准确，可以尝试该特性。</li>
                <li><code><span class="token property">useShell</span></code>
                  使用该特性后，将使用shell命令获取当前正在运行的应用的包名、活动名称，但是需要root权限。</li>
              </ul>
            </li>
          </ul>
          <p>启用有关automator的一些特性。例如：</p>
          <div class="language-javascript ext-js line-numbers-mode"><button class="copy" aria-label="复制代码"
              data-copied="已复制" data-balloon-pos="left">
              <div class="copy-icon"></div>
            </button>
            <pre class="language-javascript" copy-code-registered=""><code>auto<span class="token punctuation">.</span><span class="token function">setFlags</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">"findOnUiThread"</span><span class="token punctuation">,</span> <span class="token string">"useShell"</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="auto-service" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-service" aria-hidden="true">#</a>
            auto.service</h2>
          <p><strong>[v4.1.0新增]</strong></p>
          <ul>
            <li>{<a href="https://developer.android.com/reference/android/accessibilityservice/AccessibilityService"
                target="_blank" rel="noopener noreferrer">AccessibilityService<span><svg class="external-link-icon"
                    xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px"
                    viewBox="0 0 100 100" width="15" height="15">
                    <path fill="currentColor"
                      d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                    </path>
                    <polygon fill="currentColor"
                      points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                    </polygon>
                  </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>}</li>
          </ul>
          <p>获取无障碍服务。如果无障碍服务没有启动，则返回<code><span class="token keyword">null</span></code>。</p>
          <p>参见<a href="https://developer.android.com/reference/android/accessibilityservice/AccessibilityService"
              target="_blank" rel="noopener noreferrer">AccessibilityService<span><svg class="external-link-icon"
                  xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px"
                  viewBox="0 0 100 100" width="15" height="15">
                  <path fill="currentColor"
                    d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                  </path>
                  <polygon fill="currentColor"
                    points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                  </polygon>
                </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>。</p>
          <h2 id="auto-windows" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-windows" aria-hidden="true">#</a>
            auto.windows</h2>
          <p><strong>[v4.1.0新增]</strong></p>
          <ul>
            <li>{Array}</li>
          </ul>
          <p>当前所有窗口(<a href="https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo"
              target="_blank" rel="noopener noreferrer">AccessibilityWindowInfo<span><svg class="external-link-icon"
                  xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px"
                  viewBox="0 0 100 100" width="15" height="15">
                  <path fill="currentColor"
                    d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                  </path>
                  <polygon fill="currentColor"
                    points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                  </polygon>
                </svg><span class="external-link-icon-sr-only">open in new
                  window</span></span></a>)的数组，可能包括状态栏、输入法、当前应用窗口，弹出窗口、悬浮窗、分屏应用窗口等。可以分别获取每个窗口的布局信息。</p>
          <p>该函数需要Android 5.0以上才能运行。</p>
          <h2 id="auto-root" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-root" aria-hidden="true">#</a> auto.root
          </h2>
          <p><strong>[v4.1.0新增]</strong></p>
          <ul>
            <li>{UiObject}</li>
          </ul>
          <p>当前窗口的布局根元素。如果无障碍服务未启动或者WindowFilter均返回false，则会返回<code><span class="token keyword">null</span></code>。</p>
          <p>如果不设置windowFilter，则当前窗口即为活跃的窗口（获取到焦点、正在触摸的窗口）；如果设置了windowFilter，则获取的是过滤的窗口中的第一个窗口。</p>
          <p>如果系统是Android5.0以下，则始终返回当前活跃的窗口的布局根元素。</p>
          <h2 id="auto-rootinactivewindow" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-rootinactivewindow"
              aria-hidden="true">#</a> auto.rootInActiveWindow</h2>
          <p><strong>[v4.1.0新增]</strong></p>
          <ul>
            <li>{UiObject}</li>
          </ul>
          <p>当前活跃的窗口（获取到焦点、正在触摸的窗口）的布局根元素。如果无障碍服务未启动则为<code><span class="token keyword">null</span></code>。</p>
          <h2 id="auto-setwindowfilter-filter" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-setwindowfilter-filter"
              aria-hidden="true">#</a> auto.setWindowFilter(filter)</h2>
          <p><strong>[v4.1.0新增]</strong></p>
          <ul>
            <li><code><span class="token property">filter</span></code> {Function} 参数为窗口(<a
                href="https://developer.android.com/reference/android/view/accessibility/AccessibilityWindowInfo"
                target="_blank" rel="noopener noreferrer">AccessibilityWindowInfo<span><svg class="external-link-icon"
                    xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px"
                    viewBox="0 0 100 100" width="15" height="15">
                    <path fill="currentColor"
                      d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                    </path>
                    <polygon fill="currentColor"
                      points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                    </polygon>
                  </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>)，返回值为Boolean的函数。
            </li>
          </ul>
          <p>设置窗口过滤器。这个过滤器可以决定哪些窗口是目标窗口，并影响选择器的搜索。例如，如果想要选择器在所有窗口（包括状态栏、输入法等）中搜索，只需要使用以下代码：</p>
          <div class="language-javascript ext-js line-numbers-mode"><button class="copy" aria-label="复制代码"
              data-copied="已复制" data-balloon-pos="left">
              <div class="copy-icon"></div>
            </button>
            <pre class="language-javascript" copy-code-registered=""><code>auto<span class="token punctuation">.</span><span class="token function">setWindowFilter</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token parameter">window</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">//不管是如何窗口，都返回true，表示在该窗口中搜索</span>
    <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <p>又例如，当前使用了分屏功能，屏幕上有Auto.js和QQ两个应用，但我们只想选择器对QQ界面进行搜索，则：</p>
          <div class="language-javascript ext-js line-numbers-mode"><button class="copy" aria-label="复制代码"
              data-copied="已复制" data-balloon-pos="left">
              <div class="copy-icon"></div>
            </button>
            <pre class="language-javascript" copy-code-registered=""><code>auto<span class="token punctuation">.</span><span class="token function">setWindowFilter</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token parameter">window</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token comment">// 对于应用窗口，他的title属性就是应用的名称，因此可以通过title属性来判断一个应用</span>
    <span class="token keyword">return</span> window<span class="token punctuation">.</span>title <span class="token operator">==</span> <span class="token string">"QQ"</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <p>选择器默认是在当前活跃的窗口中搜索，不会搜索诸如悬浮窗、状态栏之类的，使用WindowFilter则可以控制搜索的窗口。</p>
          <p>需要注意的是， 如果WindowFilter返回的结果均为false，则选择器的搜索结果将为空。</p>
          <p>另外setWindowFilter函数也会影响<code>auto<span class="token punctuation">.</span>windowRoots</code>的结果。</p>
          <p>该函数需要Android 5.0以上才有效。</p>
          <h2 id="auto-windowroots" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-windowroots" aria-hidden="true">#</a>
            auto.windowRoots</h2>
          <p><strong>[v4.1.0新增]</strong></p>
          <ul>
            <li>{Array}</li>
          </ul>
          <p>返回当前被WindowFilter过滤的窗口的布局根元素组成的数组。</p>
          <p>如果系统是Android5.0以下，则始终返回当前活跃的窗口的布局根元素的数组。</p>
          <h1 id="automator" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#automator" aria-hidden="true">#</a> automator
          </h1>
          <p>automator提供了一些模拟简单操作的函数，例如点击文字、模拟按键等。部分函数可以直接作为全局函数使用。</p>
          <h2 id="click-text-i" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#click-text-i" aria-hidden="true">#</a>
            click(text[, i])</h2>
          <ul>
            <li><code><span class="token property">text</span></code> {string} 要点击的文本</li>
            <li><code><span class="token property">i</span></code> {number} 如果相同的文本在屏幕中出现多次，则i表示要点击第几个文本, i从0开始计算</li>
          </ul>
          <p>返回是否点击成功。当屏幕中并未包含该文本，或者该文本所在区域不能点击时返回false，否则返回true。</p>
          <p>该函数可以点击大部分包含文字的按钮。例如微信主界面下方的"微信", "联系人", "发现", "我"的按钮。<br> 通常与while同时使用以便点击按钮直至成功。例如:</p>
          <div class="language-javascript ext-js line-numbers-mode"><button class="copy" aria-label="复制代码"
              data-copied="已复制" data-balloon-pos="left">
              <div class="copy-icon"></div>
            </button>
            <pre class="language-javascript" copy-code-registered=""><code><span class="token keyword">while</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">click</span><span class="token punctuation">(</span><span class="token string">"扫一扫"</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
            </div>
          </div>
          <p>当不指定参数i时则会尝试点击屏幕上出现的所有文字text并返回是否全部点击成功。</p>
          <p>i是从0开始计算的, 也就是,
            <code><span class="token function">click</span><span class="token punctuation">(</span><span class="token string">"啦啦啦"</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span></code>表示点击屏幕上第一个"啦啦啦",
            <code><span class="token function">click</span><span class="token punctuation">(</span><span class="token string">"啦啦啦"</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span></code>表示点击屏幕上第二个"啦啦啦"。
          </p>
          <blockquote>
            <p>文本所在区域指的是，从文本处向其父视图寻找，直至发现一个可点击的部件为止。</p>
          </blockquote>
          <h2 id="click-left-top-bottom-right" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#click-left-top-bottom-right"
              aria-hidden="true">#</a> click(left, top, bottom, right)</h2>
          <ul>
            <li><code><span class="token property">left</span></code> {number} 要点击的长方形区域左边与屏幕左边的像素距离</li>
            <li><code><span class="token property">top</span></code> {number} 要点击的长方形区域上边与屏幕上边的像素距离</li>
            <li><code><span class="token property">bottom</span></code> {number} 要点击的长方形区域下边与屏幕下边的像素距离</li>
            <li><code><span class="token property">right</span></code> {number} 要点击的长方形区域右边与屏幕右边的像素距离</li>
          </ul>
          <p><strong>注意，该函数一般只用于录制的脚本中使用，在自己写的代码中使用该函数一般不要使用该函数。</strong></p>
          <p>点击在指定区域的控件。当屏幕中并未包含与该区域严格匹配的区域，或者该区域不能点击时返回false，否则返回true。</p>
          <p>
            有些按钮或者部件是图标而不是文字（例如发送朋友圈的照相机图标以及QQ下方的消息、联系人、动态图标），这时不能通过<code><span class="token function">click</span><span class="token punctuation">(</span>text<span class="token punctuation">,</span> i<span class="token punctuation">)</span></code>来点击，可以通过描述图标所在的区域来点击。left,
            bottom, top, right描述的就是点击的区域。</p>
          <p>至于要定位点击的区域，可以在悬浮窗使用布局分析工具查看控件的bounds属性。</p>
          <p>通过无障碍服务录制脚本会生成该语句。</p>
          <h2 id="longclick-text-i" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#longclick-text-i" aria-hidden="true">#</a>
            longClick(text[, i]))</h2>
          <ul>
            <li><code><span class="token property">text</span></code> {string} 要长按的文本</li>
            <li><code><span class="token property">i</span></code> {number} 如果相同的文本在屏幕中出现多次，则i表示要长按第几个文本, i从0开始计算</li>
          </ul>
          <p>返回是否点击成功。当屏幕中并未包含该文本，或者该文本所在区域不能点击时返回false，否则返回true。</p>
          <p>当不指定参数i时则会尝试点击屏幕上出现的所有文字text并返回是否全部长按成功。</p>
          <h2 id="scrollup-i" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#scrollup-i" aria-hidden="true">#</a>
            scrollUp([i])</h2>
          <ul>
            <li><code><span class="token property">i</span></code> {number} 要滑动的控件序号</li>
          </ul>
          <p>找到第i+1个可滑动控件上滑或<strong>左滑</strong>。返回是否操作成功。屏幕上没有可滑动的控件时返回false。</p>
          <p>
            另外不加参数时<code><span class="token function">scrollUp</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>会寻找面积最大的可滑动的控件上滑或左滑，例如微信消息列表等。
          </p>
          <p>参数为一个整数i时会找到第i +
            1个可滑动控件滑动。例如<code><span class="token function">scrollUp</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span></code>为滑动第一个可滑动控件。
          </p>
          <h2 id="scrolldown-i" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#scrolldown-i" aria-hidden="true">#</a>
            scrollDown([i])</h2>
          <ul>
            <li><code><span class="token property">i</span></code> {number} 要滑动的控件序号</li>
          </ul>
          <p>找到第i+1个可滑动控件下滑或<strong>右滑</strong>。返回是否操作成功。屏幕上没有可滑动的控件时返回false。</p>
          <p>
            另外不加参数时<code><span class="token function">scrollUp</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>会寻找面积最大的可滑动的控件下滑或右滑。
          </p>
          <p>参数为一个整数i时会找到第i +
            1个可滑动控件滑动。例如<code><span class="token function">scrollUp</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span></code>为滑动第一个可滑动控件。
          </p>
          <h2 id="settext-i-text" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#settext-i-text" aria-hidden="true">#</a>
            setText([i, ]text)</h2>
          <ul>
            <li><code><span class="token property">i</span></code> {number} 表示要输入的为第i + 1个输入框</li>
            <li><code><span class="token property">text</span></code> {string} 要输入的文本</li>
          </ul>
          <p>返回是否输入成功。当找不到对应的文本框时返回false。</p>
          <p>
            不加参数i则会把所有输入框的文本都置为text。例如<code><span class="token function">setText</span><span class="token punctuation">(</span><span class="token string">"测试"</span><span class="token punctuation">)</span></code>。
          </p>
          <p>这里的输入文本的意思是，把输入框的文本置为text，而不是在原来的文本上追加。</p>
          <h2 id="input-i-text" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#input-i-text" aria-hidden="true">#</a>
            input([i, ]text)</h2>
          <ul>
            <li><code><span class="token property">i</span></code> {number} 表示要输入的为第i + 1个输入框</li>
            <li><code><span class="token property">text</span></code> {string} 要输入的文本</li>
          </ul>
          <p>返回是否输入成功。当找不到对应的文本框时返回false。</p>
          <p>
            不加参数i则会把所有输入框的文本追加内容text。例如<code><span class="token function">input</span><span class="token punctuation">(</span><span class="token string">"测试"</span><span class="token punctuation">)</span></code>。
          </p>
          <h2 id="automator-takescreenshot" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#automator-takescreenshot"
              aria-hidden="true">#</a> automator.takeScreenshot()</h2>
          <p><strong>[<a href="/" target="_blank" rel="noopener noreferrer">Pro 8.8.0新增<span><svg
                    class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"
                    x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                    <path fill="currentColor"
                      d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                    </path>
                    <polygon fill="currentColor"
                      points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                    </polygon>
                  </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>]]</strong></p>
          <ul>
            <li>返回 {Image}</li>
          </ul>
          <p>使用无障碍权限截图，返回一个Image对象。</p>
          <p>相比起images模块申请截图权限截图，该函数不需要额外权限，但是有以下限制：</p>
          <ul>
            <li>截图频率限制。系统限制截图最多一秒一次，否则抛出异常</li>
            <li>需要Android 11及以上版本</li>
          </ul>
          <div class="language-javascript ext-js line-numbers-mode"><button class="copy" aria-label="复制代码"
              data-copied="已复制" data-balloon-pos="left">
              <div class="copy-icon"></div>
            </button>
            <pre class="language-javascript" copy-code-registered=""><code>$auto<span class="token punctuation">.</span><span class="token function">waitFor</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> capture <span class="token operator">=</span> $automator<span class="token punctuation">.</span><span class="token function">takeScreenshot</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
$images<span class="token punctuation">.</span><span class="token function">save</span><span class="token punctuation">(</span>capture<span class="token punctuation">,</span> <span class="token string">"../capture.png"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="automator-switchtoinputmethod-packagename" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#automator-switchtoinputmethod-packagename"
              aria-hidden="true">#</a> automator.switchToInputMethod(packageName)</h2>
          <p><strong>[<a href="/" target="_blank" rel="noopener noreferrer">Pro 8.8.0新增<span><svg
                    class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"
                    x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                    <path fill="currentColor"
                      d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                    </path>
                    <polygon fill="currentColor"
                      points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                    </polygon>
                  </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>]</strong></p>
          <ul>
            <li><code><span class="token property">packageName</span></code> {string} 输入法包名</li>
            <li>返回 {boolean}</li>
          </ul>
          <p>切换到指定输入法，返回是否成功。失败的情况有以下可能：</p>
          <ul>
            <li>指定包名的输入法不存在或未启用</li>
            <li>系统返回切换输入法失败</li>
          </ul>
          <p>此函数需要Android 11及以上。</p>
          <div class="language-javascript ext-js line-numbers-mode"><button class="copy" aria-label="复制代码"
              data-copied="已复制" data-balloon-pos="left">
              <div class="copy-icon"></div>
            </button>
            <pre class="language-javascript" copy-code-registered=""><code><span class="token comment">// 切换到搜狗输入法</span>
$automator<span class="token punctuation">.</span><span class="token function">switchToInputMethod</span><span class="token punctuation">(</span><span class="token string">'com.sohu.inputmethod.sogou'</span><span class="token punctuation">)</span>
</code></pre>
            <div class="line-numbers" aria-hidden="true">
              <div class="line-number"></div>
              <div class="line-number"></div>
            </div>
          </div>
          <h2 id="automator-headsethook" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#automator-headsethook" aria-hidden="true">#</a>
            automator.headsetHook()</h2>
          <p><strong>[<a href="/" target="_blank" rel="noopener noreferrer">Pro 8.8.0新增<span><svg
                    class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"
                    x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
                    <path fill="currentColor"
                      d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z">
                    </path>
                    <polygon fill="currentColor"
                      points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9">
                    </polygon>
                  </svg><span class="external-link-icon-sr-only">open in new window</span></span></a>]</strong></p>
          <ul>
            <li>返回 {boolean}</li>
          </ul>
          <p>模拟耳机键，返回是否执行成功。用于挂断、接听电话，播放、暂停音乐。</p>
          <h2 id="auto-clearcache" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#auto-clearcache" aria-hidden="true">#</a>
            auto.clearCache()</h2>
          <p><strong>[v9.0.14新增]</strong></p>
          <p>
            清空无障碍缓存。当屏幕上的控件已经出现但是选择器始终无法找到该控件，可能是缓存没有刷新，此时可调用<code>auto<span class="token punctuation">.</span><span class="token function">clearCache</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>来清空控件缓存。另外，从9.0版本开始，<code><span class="token function">findOne</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>等函数在长时间找不到时也会自动清空缓存。
          </p>
          <h2 id="rect" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect" aria-hidden="true">#</a> Rect</h2>
          <p>
            <code>UiObject<span class="token punctuation">.</span><span class="token function">bounds</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>,
            <code>UiObject<span class="token punctuation">.</span><span class="token function">boundsInParent</span><span class="token punctuation">(</span><span class="token punctuation">)</span></code>返回的对象。表示一个长方形(范围)。
          </p>
          <h3 id="rect-left" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-left" aria-hidden="true">#</a> Rect.left
          </h3>
          <ul>
            <li>{number}</li>
          </ul>
          <p>长方形左边界的x坐标、</p>
          <h3 id="rect-right" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-right" aria-hidden="true">#</a> Rect.right
          </h3>
          <ul>
            <li>{number}</li>
          </ul>
          <p>长方形右边界的x坐标、</p>
          <h3 id="rect-top" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-top" aria-hidden="true">#</a> Rect.top
          </h3>
          <ul>
            <li>{number}</li>
          </ul>
          <p>长方形上边界的y坐标、</p>
          <h3 id="rect-bottom" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-bottom" aria-hidden="true">#</a>
            Rect.bottom</h3>
          <ul>
            <li>{number}</li>
          </ul>
          <p>长方形下边界的y坐标、</p>
          <h3 id="rect-centerx" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-centerx" aria-hidden="true">#</a>
            Rect.centerX()</h3>
          <ul>
            <li>返回 {number}</li>
          </ul>
          <p>长方形中点x坐标。</p>
          <h3 id="rect-centery" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-centery" aria-hidden="true">#</a>
            Rect.centerY()</h3>
          <ul>
            <li>返回 {number}</li>
          </ul>
          <p>长方形中点y坐标。</p>
          <h3 id="rect-width" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-width" aria-hidden="true">#</a>
            Rect.width()</h3>
          <ul>
            <li>返回 {number}</li>
          </ul>
          <p>长方形宽度。通常可以作为控件宽度。</p>
          <h3 id="rect-height" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-height" aria-hidden="true">#</a>
            Rect.height()</h3>
          <ul>
            <li>返回 {number}</li>
          </ul>
          <p>长方形高度。通常可以作为控件高度。</p>
          <h3 id="rect-contains-r" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-contains-r" aria-hidden="true">#</a>
            Rect.contains(r)</h3>
          <ul>
            <li><code><span class="token property">r</span></code> {<a
                href="../automator/api.html#rect">Rect</a>}</li>
          </ul>
          <p>返回是否包含另一个长方形r。包含指的是，长方形r在该长方形的里面(包含边界重叠的情况)。</p>
          <h3 id="rect-intersect-r" tabindex="-1"><a class="header-anchor"
              href="../automator/api.html#rect-intersect-r" aria-hidden="true">#</a>
            Rect.intersect(r)</h3>
          <ul>
            <li><code><span class="token property">r</span></code> {<a
                href="../automator/api.html#rect">Rect</a>}</li>
          </ul>
          <p>返回是否和另一个长方形相交。</p>
        </div><!---->
        <footer class="page-meta"><!---->
          <div class="meta-item update-time"><span class="label">上次编辑于: </span><span class="info">2022/10/27
              13:15:37</span></div>
          <div class="meta-item contributors"><span class="label">贡献者: </span><span class="contributor"
              title="email: 946994919@qq.com">hyb1996</span></div>
        </footer>
        <nav class="page-nav"><a href="../automator/uiobject.html" class="nav-link prev"
            aria-label="控件和控件集合">
            <div class="hint"><span class="arrow left"></span>上一页</div>
            <div class="link"><!---->控件和控件集合</div>
          </a><!----></nav><!----><!---->
      </main><!--]--><!----><!--]-->
    </div><!--]--><button class="back-to-top" aria-label="返回顶部" data-balloon-pos="left"><svg
        xmlns="http://www.w3.org/2000/svg" class="icon back-to-top-icon" viewBox="0 0 1024 1024" fill="currentColor"
        aria-label="back-to-top icon">
        <path
          d="M512 843.2c-36.2 0-66.4-13.6-85.8-21.8-10.8-4.6-22.6 3.6-21.8 15.2l7 102c.4 6.2 7.6 9.4 12.6 5.6l29-22c3.6-2.8 9-1.8 11.4 2l41 64.2c3 4.8 10.2 4.8 13.2 0l41-64.2c2.4-3.8 7.8-4.8 11.4-2l29 22c5 3.8 12.2.6 12.6-5.6l7-102c.8-11.6-11-20-21.8-15.2-19.6 8.2-49.6 21.8-85.8 21.8z">
        </path>
        <path
          d="m795.4 586.2-96-98.2C699.4 172 513 32 513 32S324.8 172 324.8 488l-96 98.2c-3.6 3.6-5.2 9-4.4 14.2L261.2 824c1.8 11.4 14.2 17 23.6 10.8L419 744s41.4 40 94.2 40c52.8 0 92.2-40 92.2-40l134.2 90.8c9.2 6.2 21.6.6 23.6-10.8l37-223.8c.4-5.2-1.2-10.4-4.8-14zM513 384c-34 0-61.4-28.6-61.4-64s27.6-64 61.4-64c34 0 61.4 28.6 61.4 64S547 384 513 384z">
        </path>
      </svg></button><button class="sw-update-popup" tabindex="0">新内容已就绪<span class="icon-wrapper"><svg
          xmlns="http://www.w3.org/2000/svg" class="icon update-icon" viewBox="0 0 1024 1024" fill="currentColor"
          aria-label="update icon">
          <path
            d="M949.949 146.25v255.826c0 21.981-13.989 35.97-35.97 35.97H658.154c-13.988 0-25.983-7.992-33.973-21.981-5.997-13.989-4-27.977 7.991-39.97l79.942-77.946c-55.954-51.973-121.918-77.955-199.863-77.955-37.975 0-75.95 8.002-113.924 21.99-37.975 15.985-67.948 37.976-91.934 63.957-25.982 23.987-47.973 53.96-63.957 91.934-29.983 73.955-29.983 153.895 0 227.85 15.984 37.976 37.975 67.947 63.957 91.934 23.986 25.982 53.959 47.973 91.934 63.956 37.974 13.989 75.95 21.991 113.924 21.991 45.967 0 87.942-9.998 127.913-29.982 41.976-17.99 75.951-45.967 101.931-83.943 7.993-4 11.994-5.995 13.989-5.995 5.997 0 9.998 1.994 13.988 5.995l77.958 77.946c3.989 4 5.986 7.993 5.986 11.994 0 1.994-1.996 5.995-3.99 11.994-43.973 51.962-93.941 91.934-151.9 117.914-53.958 25.983-115.92 39.972-185.874 39.972-61.961 0-119.921-11.984-169.89-33.973-57.96-25.985-105.923-57.963-139.896-93.943-35.98-33.972-67.958-81.936-93.94-139.897-45.967-101.93-45.967-237.846 0-339.777 25.982-57.96 57.96-105.923 93.94-139.896 33.973-35.98 81.936-67.958 139.896-93.94 49.968-21.99 107.928-33.974 169.89-33.974 55.963 0 109.923 9.988 161.885 29.973 53.97 21.99 101.933 51.963 139.908 89.938l73.954-73.944c9.987-9.998 23.987-13.988 39.971-8.002 13.988 8.002 21.98 19.995 21.98 33.984z">
          </path>
        </svg></span></button><!--]-->
  </div>
  <script type="module" src="./automator与其他函数 _ Auto.js Pro文档_files/app.486b1949.js.下载" defer=""></script>


  <div id="message-container"></div>
</body>
<div id="photoShowViewer" class="sb_BingCA photoShow">
  <div class="photoshow-viewer-shadow"></div>
  <div class="photoshow-img-wrapper">
    <img>
    <div class="photoshow-view-mode-switch-tip">a</div>
  </div>
  <i class="photoshow-img-size"></i>
</div>

</html>